<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/3
 * Time: 1:21
 */

namespace Xcx\Controller;

use Xcx\Common\ErrorCode;
use Xcx\Model\GoodsBargainDetailsModel;
use Xcx\Model\GoodsBargainModel;

class GoodsBargainController extends BaseController
{
    /**
     * 获取砍价页面详细信息
     */
    public function getBargainInfo()
    {
        $orderNo = I('order_no');

        $GoodsBargain = new GoodsBargainModel();
        $data = $GoodsBargain->getBargainDetailsInfo($orderNo);
        if ($data) {
            $arr['code'] = 0;
            $arr['data'] = $data;
        } else {
            $arr = array('code'=>ErrorCode::$Fail,'msg'=>'信息获取失败');
        }

        $this->ajaxReturn($arr);
    }

    /**
     * 砍价
     */
    public function doBargain()
    {
        $orderNo = I('order_no');
        $BargainDetail = new GoodsBargainDetailsModel();
        $res = $BargainDetail->doBargain($orderNo);
        if ($res) {
            $arr['code'] = 0;
        } else {
            $arr = array('code'=>ErrorCode::$Fail,'msg'=>$BargainDetail->getErrMsg());
        }

        $this->ajaxReturn($arr);
    }
}